#ifndef MINI_ENGINE_MODEL
#define MINI_ENGINE_MODEL

#include <vulkan/vulkan.h>
using namespace std;
#include <vector>
#include <glm/glm.hpp>
#include <array>
#include "LogicalDevice.h"

namespace mini_engine
{

    struct Vertex
    {
        glm::vec2 pos;
        glm::vec3 color;

        static VkVertexInputBindingDescription getBindingDescription()
        {
            VkVertexInputBindingDescription bindingDescription{};
            bindingDescription.binding = 0;
            bindingDescription.stride = sizeof(Vertex);
            bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;

            return bindingDescription;
        }

        static array<VkVertexInputAttributeDescription, 2> getAttributeDescriptions()
        {
            array<VkVertexInputAttributeDescription, 2> attributeDescriptions{};

            attributeDescriptions[0].binding = 0;
            attributeDescriptions[0].location = 0;
            attributeDescriptions[0].format = VK_FORMAT_R32G32_SFLOAT;
            attributeDescriptions[0].offset = offsetof(Vertex, pos);

            attributeDescriptions[1].binding = 0;
            attributeDescriptions[1].location = 1;
            attributeDescriptions[1].format = VK_FORMAT_R32G32B32_SFLOAT;
            attributeDescriptions[1].offset = offsetof(Vertex, color);

            return attributeDescriptions;
        }
    };

    const vector<Vertex> vertices = {
        {{0.0f, -0.5f}, {1.0f, 0.0f, 0.0f}},
        {{0.5f, 0.5f}, {0.0f, 1.0f, 0.0f}},
        {{-0.5f, 0.5f}, {0.0f, 0.0f, 1.0f}}
        };
    class Model
    {
    private:
        Model();
        static Model *m_Model;
        uint32_t findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties);
        class ModelDestruction
        {
        public:
            ~ModelDestruction();
        };

    public:
        static VkBuffer vertexBuffer;
        static VkDeviceMemory vertexBufferMemory;
        static Model *getModel();
        void createVertexBuffer();
        ~Model();
    };

}

#endif